Present invention embodiments are related to systems, methods and computer program products for detecting over-access of shared memory that is shared across multiple processes. In particular, present invention embodiments are related to systems, methods and computer program products for detecting a point at which an area of shared memory, which is not intended for use by an application, is read or written by the application.
One existing memory manager provides an ability to allocate memory shared among multiple processes. Any of the processes could access the same shared memory with the same handle value used by the memory manager to identify an allocated portion of the shared memory. When program code reads or writes to a buffer of shared memory beyond an end of the buffer, program code and/or data may become corrupted. As a result, at a later time when the corrupted program code is executed or the corrupted data is used, the program code may crash, thereby making it difficult to determine which part of the program code was a root cause of the crash because the crash may not occur close in time to an occurrence of the root cause.
One method of debugging memory over-access, provided by a Microsoft Windows operating system (available from Microsoft Corporation of Redmond, Wash.), includes an inaccessible memory page following every buffer allocated from a process' private memory manager. However, this method does not work with memory shared among multiple processes.
Another memory manager currently uses a debug method for detecting whether a shared memory was overwritten. The debug method includes adding a signature at end bytes of each allocated buffer of shared memory. When program code translates a handle value of an allocated buffer of shared memory to a native memory pointer or frees the buffer, the end bytes of the buffer are checked to determine whether the signature remains unchanged. Shared memory is determined to be overwritten when the signature at the end bytes is determined to be changed. However, when using this debug method, it remains difficult to determine an exact point at which the shared memory is overwritten. Further complicating debug efforts, the program code could crash while executing a totally unrelated function that uses a corrupted portion of the shared memory before the end bytes of the buffer are checked for the signature. In addition, this method does not address reading data beyond a usable portion of a buffer of shared memory.